using System.Collections.Generic;
using FlowCanvas.Nodes;
using Yoozoo.Gameplay.Liberty.AI;

namespace Yoozoo.Gameplay.Liberty.StreetEvent
{
    public class ChangeAllStreeFightMonsterStatus : CallableActionNode
    {
        public SideType sideType = SideType.Madness;
        public NpcStatus npcStatus = NpcStatus.Battle;
        public bool autoRevenge = true;
        public bool resetToIdle;
        public override void Invoke()
        {
            Dictionary<int, StreetEventMonsterData> monsterId2InfoMap = StreetEventManager.GetInstance().monsterId2InfoMap;
            foreach (var m in monsterId2InfoMap.Values)
            {
                var aiEntity = LibertyAIUtils.AIManager.NpcBirthManager.GetNpc(m.uniqueId);
                if (aiEntity != null)
                {
                    aiEntity.data.side = sideType;
                    aiEntity.data.npcStatus = npcStatus;

                    if (resetToIdle)
                    {
                        aiEntity.viewer.animationAgent.PlayIdleAnimation();
                    }

                    if (npcStatus == NpcStatus.Battle && autoRevenge)
                    {
                        aiEntity.battleAgent.revengeTarget = LibertyAIUtils.GetPlayerEntity();
                        aiEntity.battleAgent.revengeColdDuration = -1;  // 永久仇恨
                    }
                }
            }
        }
    }
}